import config from '@/config'
import RequestBase from '@/utils/request.js'
import { getDeptCount, getPersonAndCarCount } from '@/pages/work/person-stat/util/polygon'
import Store from '@/store'
const request = new RequestBase(config.baseUrl)
const $store = Store.getters

/**
 * @description 区域部门人车统计
 */
export function getStatData() {
  console.log('areaStatList', $store.areaStatList, $store.onLineCarList, $store.onLinePersonList)
  const areaList = $store.areaStatList.map((item) => ({
    carCount: 0,
    personnelCount: 0,
    key: item.areaId,
    boundary: item.boundary
  }))

  return new Promise((resolve) => {
    resolve({
      data: {
        areaStats: getPersonAndCarCount(areaList),
        deptStats: getDeptCount()
      }
    })
  })
}
/**
 * @description getModelId
 */
export function getModelList() {
  return request.get(`/basic-info/info/web/model3d/pages`, { pageSize: 1 })
}

export function getVehicleTypeList() {
  return request.get(`/basic-info/info/web/business-type/list?businessCategory=11&pageNum=1&pageSize=1000`)
}

/**
 * @description 区域
 */
export function getAreaData() {
  return request.get(`/basic-info/info/web/factory-area/getTree`)
}

/**
 * @description 部门
 */
export function getDeptData() {
  return request.get(`/portal/auth/dept/api/v1/tree?containChildren=true&withCount=true`)
}

/**
 * 添加作业项目
 */
export function createWorkProject(data) {
  return request.post('/spw/work-project', data)
}
